﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using CompactMapper.Orm.Contracts;
using CompactMapper.Orm.Queries;
using CompactMapper.Orm.UnitOfWork.Mappings;

namespace CompactMapper.Orm.Tests.Transactions
{
    public class ThrowOnInsertMappings : IMappings
    {
        private readonly IMappings _mappings;

        public ThrowOnInsertMappings(IMappings mappings)
        {
            _mappings = mappings;
        }

        public void RunCreate(SQLiteConnection connection)
        {
            _mappings.RunCreate(connection);
        }

        public IEnumerable<T> RunGetAll<T>(SQLiteConnection connection) where T : class
        {
            return _mappings.RunGetAll<T>(connection);
        }

        public IEnumerable<T> RunQuery<T>(SQLiteConnection connection, Query query) where T : class
        {
            return _mappings.RunQuery<T>(connection, query);
        }

        public void RunInsert(SQLiteConnection connection, IEnumerable<IKeyedPersistent> toInsert)
        {
            throw new NotImplementedException();
        }

        public void RunDelete<T>(SQLiteConnection connection, IKey toDelete) where T : class, IKeyedPersistent
        {
            _mappings.RunDelete<T>(connection, toDelete);
        }

        public void RunDeleteAll<T>(SQLiteConnection connection)
        {
            _mappings.RunDeleteAll<T>(connection);
        }

        public MemoryStream DumpSchema()
        {
            return _mappings.DumpSchema();
        }
    }
}